window.status = "_java_";

java = {
	readurl :  function (url) {
		var s;
		$.ajaxSetup({  async : false }); 
	    $.get(url, null, function(data) { s = data });
	    $.ajaxSetup({  async : true }); 
	    return s;
	},
	
	groovy : function (url) {
		var s = java.readurl(url);
		return _java_.groovy(s);
	},
	
	exit : function () {
		_java_.exit();
	},
	
	debug : function (s) {
		_java_.debug(s);
	}
};

String.prototype.format = function() {
    var result=this;
    if (arguments.length == 0)
        return this;
    for ( var i = 0; i < arguments.length; i++) {
        var re = new RegExp('\\{' + (i) + '\\}', 'gm');
        result = result.replace(re, arguments[i]);
    }
    return result;
};